<form name="form1" enctype="multipart/form-data" method="post" action="excelread.php">
  <input type="file" name="myfile">
  <input type="submit" name="LoadFile" value="Submit">
</form>

<?php

require_once 'ClsSebent/Excel/reader.php';

if(isset($_POST['LoadFile']) && ($_POST['LoadFile']!=''))
{
		$addonFileName=$_FILES['myfile']['tmp_name'];
		//echo $addonFileName;
		$product_id=1;//to be passed in the function.
		$data = new Spreadsheet_Excel_Reader();
		$data->setOutputEncoding('CP1251');
		$data->setUTFEncoder('mb');
		$data->read($addonFileName);
		error_reporting(E_ALL ^ E_NOTICE);		
				
				for ($i = 5; $i <= $data->sheets[0]['numRows']-1; $i++)
				{						echo "<br>";
//				echo "I ".$i; echo " cellvalue ".$data->sheets[0]['cells'][$i][1]."<br>";					
						if(($data->sheets[0]['cells'][$i][1]!="") && ($data->sheets[0]['cells'][$i][2]!="") && ($data->sheets[0]['cells'][$i][3]!=""))
						{ //echo "Hi";
								for ($j = 2; $j <= $data->sheets[0]['numCols']; $j++) 
								{	
									//leave column 2 every time.
									$lot_size_m=$lot_size_h=0;
										$lot_limits=explode("-",$data->sheets[0]['cells'][$i][1]);
										$lot_size_m=str_replace("+","",$lot_limits[0]);
										if($lot_limits[1]!=0)
										{
											$lot_size_h=$lot_limits[1];
										}
									
										$no_of_colors=$data->sheets[0]['cells'][3][$j];
										$no_of_colors=str_replace("(","",$no_of_colors);
										$no_of_colors=str_replace(")","",$no_of_colors);
										$lot_price=$data->sheets[0]['cells'][$i][$j];
									
									
									//echo "color: ".$data->sheets[0]['cells'][$i][1]." Size: ".$data->sheets[0]['cells'][1][$j]." cost: ".str_replace("$","", $data->sheets[0]['cells'][$i][$j])." -- ";
									$qry="INSERT INTO PRODUCT_LOT_PRICING(product_id, lot_size_m, lot_size_h, no_of_colors, lot_price) VALUES(".
									$product_id.",".
									$lot_size_m.",".
									$lot_size_h.",".
									$no_of_colors.",".							
									$lot_price
									.")";
									
									echo $qry."<br>";		
									//mysql_query(mysql_escape_string($qry));
								}//END FOR
						}//END IF									
				}
}
?>